<!-- 发送聊天群成员 -->
<template>
  <div class="ready-user-content">
    <header>{{ content.name }}</header>
    <div class="user-content">
      <div class="user-list_box">
        <div
          class="user_item"
          v-for="member in content.memberList"
          :key="member.id"
        >
          <chat-avatar
            :size="40"
            :content="member.avatar || member.name"
          ></chat-avatar>
        </div>
      </div>
      <div v-if="content.memberList" class="send_msg_btn">
        <el-button type="primary" @click="handleSendMessage"
          >发送消息</el-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex"
import chatAvatar from "../common/avatar.vue"
export default {
  components: { chatAvatar },
  props: {
    content: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {}
  },
  computed: {
    ...mapState(["recentChatList", "recentTopChatList"])
  },

  methods: {
    handleSendMessage() {
      this.$store.commit("setIsGroup", true)
      this.setChatIdByReceiverId()
      this.$store.commit("setSelectedMenu", "badge")
    },
    setChatIdByReceiverId() {
      const chatList = [...this.recentTopChatList, ...this.recentChatList]
      const curChat = chatList.find(
        (item) => item.receiverId === this.content.id
      )
      if (curChat) {
        this.$store.commit("setCurrentChatInfo", curChat)
        this.$store.commit("setChatId", curChat.id)
        if (curChat.isShow === false) {
          //调取显示
        }
        this.$store.commit("updateActionChat", { id: curChat.id, isShow: true }) //更新排序
      }
    }
  }
}
</script>
<style lang="less" scoped>
.ready-user-content {
  width: 100%;
  height: 100%;
  background: #f7f8fa;
  display: flex;
  flex-direction: column;
}
header {
  padding: 20px;
  font-size: 14px;
  color: #333333;
  font-weight: 600;
}
.user-list_box {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  width: 100%;
  .user_item {
    margin: 16px;
  }
}

.user-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.send_msg_btn {
  display: flex;
  padding-top: 100px;
  justify-content: center;
}
</style>
